struct Stu {
    name: String,
    university: String,
    fav_language: String,
    git_username: String,
}

impl Programmer for Stu {
    fn fav_language(&self) -> String {
        self.fav_language.clone()
    }
}

impl Student for Stu {
    fn university(&self) -> String {
        self.university.clone()
    }
}

impl Person for Stu {
    fn name(&self) -> String {
        self.name.clone()
    }
}

impl CompSciStudent for Stu {
    fn git_username(&self) -> String {
        self.git_username.clone()
    }
}

fn main() {
    println!(
        "{}",
        comp_sci_student_greeting(&Stu {
            name: String::from("LiShixi"),
            university: String::from("清华大学"),
            fav_language: String::from("Rust"),
            git_username: String::from("LiShixi@gmail.com"),
        })
    );
}

trait Person {
    fn name(&self) -> String;
}
trait Student: Person {
    fn university(&self) -> String;
}

trait Programmer {
    fn fav_language(&self) -> String;
}

trait CompSciStudent: Programmer + Student {
    fn git_username(&self) -> String;
}

fn comp_sci_student_greeting(student: &dyn CompSciStudent) -> String {
    format!(
        "我叫 {}，在 {} 上课。我最喜欢的语言是{}。我的 Git 用户名是{}。",
        student.name(),
        student.university(),
        student.fav_language(),
        student.git_username()
    )
}
